package com.example.pei.ithinklearnt.adapter;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.example.pei.ithinklearnt.view.fragments.PersonalFragment;
import com.example.pei.ithinklearnt.view.fragments.HomeFragment;
import com.example.pei.ithinklearnt.view.fragments.MessageFragment;
import com.example.pei.ithinklearnt.view.fragments.SkillFragment;


import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class tabbarViewPageAdapter extends FragmentPagerAdapter {

    private List<Fragment> fragments = new ArrayList<>();
   // private Fragment currentFragment;

    public tabbarViewPageAdapter(FragmentManager fm) {
        super(fm);
        fragments.clear();
        fragments.add(new HomeFragment());
        fragments.add(new MessageFragment());
        fragments.add(new SkillFragment());
        fragments.add(new PersonalFragment());
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
//        if (getCurrentFragment() != object) {
//            currentFragment = ((Fragment) object);
//        }
        super.setPrimaryItem(container, position, object);
    }

    /**
     * Get the current fragment
     */
  //  public Fragment getCurrentFragment() {
  //      return currentFragment;
  //  }
}
